﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Goldlight.Mvvm.Base;
using System.Collections.ObjectModel;
using Goldlight.Mvvm.Base.Infrastructure;

namespace Goldlight.SampleApplication.ViewModels.ControlPanel
{
    public class ControlPanelViewModel : ControlPanelViewModelBase
    {
        private ReadOnlyCollection<ControlPanelViewModelBase> _panels;
        private ControlPanelViewModelBase _currentPanel = null;

        /// <summary>
        /// Get the list of available panels.
        /// </summary>
        public ReadOnlyCollection<ControlPanelViewModelBase> Panels
        {
            get { return _panels; }
        }

        protected override void OnInitialize()
        {
            base.OnInitialize();

            List<ControlPanelViewModelBase> list = new List<ControlPanelViewModelBase>();
            list.Add(new AccountControlPanelViewModel());

            _panels = new ReadOnlyCollection<ControlPanelViewModelBase>(list);

            _currentPanel = list[0];
        }

        /// <summary>
        /// Get the current panel to display in the UI.
        /// </summary>
        public ControlPanelViewModelBase CurrentPanel
        {
            get { return _currentPanel; }
            set
            {
                if (_currentPanel != value)
                {
                    if (_currentPanel != null)
                    {
                        _currentPanel.IsCurrentPanel = false;
                    }
                    _currentPanel = value;
                    if (_currentPanel != null)
                    {
                        _currentPanel.IsCurrentPanel = true;
                    }
                }
            }
        }
    }
}
